package kr.pe.johnkim.checkmileage.mobile.rest.controller;

import kr.pe.johnkim.checkmileage.mobile.domain.CheckMileageMerchant;
import kr.pe.johnkim.checkmileage.mobile.rest.service.CheckMileageMerchantService;
import kr.pe.johnkim.checkmileage.mobile.util.CheckMileageCommon;
import org.codehaus.jettison.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;

/**
 * Check Mileage 가맹점 관련 Controller 클래스 이다.
 * 
 * @author : johnkim <cale9797@gmail.com / Bettersoft, Inc.>
 * @Date : 12. 7. 24
 */

@Controller
@Path("/checkMileageMerchantController")
public class CheckMileageMerchantController {

    // SLF4J Logging
	private Logger logger = LoggerFactory.getLogger(CheckMileageMerchantController.class);

    @Autowired
    private CheckMileageMerchantService checkMileageMerchantService = null;

    @Autowired
    private CheckMileageCommon checkMileageCommon = null;

    /**
     * 가맹점 아이디 중복 검사를 한다.
     * 
     * @param is
     * @return
     * @throws Exception
     */
    @POST
    @Path("/selectMerchantId")
    @Consumes({"application/json", "application/xml"})
    @Produces({"application/json", "application/xml"})
    public CheckMileageMerchant selectMerchantId(InputStream is) throws Exception {
        logger.info("selectMerchantId");

        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = br.readLine();

        logger.info("line : {}", line);

        JSONObject jsonMerchant = new JSONObject(line);
        JSONObject jsonMerchant2 = jsonMerchant.getJSONObject("checkMileageMerchant");

        CheckMileageMerchant parameterMerchant = new CheckMileageMerchant();

        parameterMerchant.setMerchantId(jsonMerchant2.getString("merchantId"));

        return checkMileageMerchantService.selectMerchantId(parameterMerchant);
    }

    /**
     * 가맹점을 등록 한다.
     * 
     * @param is
     * @return
     * @throws Exception
     */
    @POST
    @Path("/registerMerchant")
    @Consumes({"application/json", "application/xml"})
    @Produces({"application/json", "application/xml"})
    public CheckMileageMerchant registerMerchant(InputStream is) throws Exception {
        logger.info("registerMerchant");

        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = br.readLine();

        logger.info("line : {}", line);

        JSONObject jsonMerchant = new JSONObject(line);
        JSONObject jsonMerchant2 = jsonMerchant.getJSONObject("checkMileageMerchant");

        CheckMileageMerchant parameterMerchant = new CheckMileageMerchant();

        parameterMerchant.setMerchantId(jsonMerchant2.getString("merchantId"));
        parameterMerchant.setPassword(jsonMerchant2.getString("password"));
        parameterMerchant.setName(jsonMerchant2.getString("name"));
        parameterMerchant.setCompanyName(jsonMerchant2.getString("companyName"));
        parameterMerchant.setIntroduction(jsonMerchant2.getString("introduction"));
        parameterMerchant.setProfileImageUrl(jsonMerchant2.getString("profileImageUrl"));
        parameterMerchant.setProfileThumbnailImageUrl(jsonMerchant2.getString("profileThumbnailImageUrl"));
        parameterMerchant.setBirthday(jsonMerchant2.getString("birthday"));
        parameterMerchant.setOpeningDate(jsonMerchant2.getString("openingDate"));
        parameterMerchant.setEmail(jsonMerchant2.getString("email"));
        parameterMerchant.setHomePage(jsonMerchant2.getString("homePage"));
        parameterMerchant.setBlog(jsonMerchant2.getString("blog"));
        parameterMerchant.setAgencyCode(jsonMerchant2.getString("agencyCode"));
        parameterMerchant.setCountryCode(jsonMerchant2.getString("countryCode"));
        parameterMerchant.setLanguageCode(jsonMerchant2.getString("languageCode"));
        parameterMerchant.setMobilePhoneNumber(jsonMerchant2.getString("mobilePhoneNumber"));
        parameterMerchant.setHomePhoneNumber(jsonMerchant2.getString("homePhoneNumber"));
        parameterMerchant.setWorkPhoneNumber(jsonMerchant2.getString("workPhoneNumber"));
        parameterMerchant.setFaxPhoneNumber(jsonMerchant2.getString("faxPhoneNumber"));
        parameterMerchant.setZipCode01(jsonMerchant2.getString("zipCode01"));
        parameterMerchant.setAddress01(jsonMerchant2.getString("address01"));
        parameterMerchant.setAddress02(jsonMerchant2.getString("address02"));
        parameterMerchant.setZipCode02(jsonMerchant2.getString("zipCode02"));
        parameterMerchant.setAddress03(jsonMerchant2.getString("address03"));
        parameterMerchant.setAddress04(jsonMerchant2.getString("address04"));
        parameterMerchant.setZipCode03(jsonMerchant2.getString("zipCode03"));
        parameterMerchant.setAddress05(jsonMerchant2.getString("address05"));
        parameterMerchant.setAddress06(jsonMerchant2.getString("address06"));
        parameterMerchant.setZipCode04(jsonMerchant2.getString("zipCode04"));
        parameterMerchant.setAddress07(jsonMerchant2.getString("address07"));
        parameterMerchant.setAddress08(jsonMerchant2.getString("address08"));
        parameterMerchant.setZipCode05(jsonMerchant2.getString("zipCode05"));
        parameterMerchant.setAddress09(jsonMerchant2.getString("address09"));
        parameterMerchant.setAddress10(jsonMerchant2.getString("address10"));
        parameterMerchant.setBusinessType(jsonMerchant2.getString("businessType"));
        parameterMerchant.setBusinessRegistrationNumber01(jsonMerchant2.getString("businessRegistrationNumber01"));
        parameterMerchant.setBusinessRegistrationNumber02(jsonMerchant2.getString("businessRegistrationNumber02"));
        parameterMerchant.setBusinessRegistrationNumber03(jsonMerchant2.getString("businessRegistrationNumber03"));
        parameterMerchant.setBusinessRegistrationNumber04(jsonMerchant2.getString("businessRegistrationNumber04"));
        parameterMerchant.setBusinessRegistrationNumber05(jsonMerchant2.getString("businessRegistrationNumber05"));
        parameterMerchant.setBusinessRegistrationNumber06(jsonMerchant2.getString("businessRegistrationNumber06"));
        parameterMerchant.setBusinessRegistrationNumber07(jsonMerchant2.getString("businessRegistrationNumber07"));
        parameterMerchant.setBusinessRegistrationNumber08(jsonMerchant2.getString("businessRegistrationNumber08"));
        parameterMerchant.setBusinessRegistrationNumber09(jsonMerchant2.getString("businessRegistrationNumber09"));
        parameterMerchant.setBusinessRegistrationNumber10(jsonMerchant2.getString("businessRegistrationNumber10"));
        parameterMerchant.setBusinessKind01(jsonMerchant2.getString("businessKind01"));
        parameterMerchant.setBusinessKind02(jsonMerchant2.getString("businessKind02"));
        parameterMerchant.setBusinessKind03(jsonMerchant2.getString("businessKind03"));
        parameterMerchant.setBusinessKind04(jsonMerchant2.getString("businessKind04"));
        parameterMerchant.setBusinessKind05(jsonMerchant2.getString("businessKind05"));
        parameterMerchant.setBusinessArea01(jsonMerchant2.getString("businessArea01"));
        parameterMerchant.setBusinessArea02(jsonMerchant2.getString("businessArea02"));
        parameterMerchant.setBusinessArea03(jsonMerchant2.getString("businessArea03"));
        parameterMerchant.setBusinessArea04(jsonMerchant2.getString("businessArea04"));
        parameterMerchant.setBusinessArea05(jsonMerchant2.getString("businessArea05"));
        parameterMerchant.setLatitude(jsonMerchant2.getString("latitude"));
        parameterMerchant.setLongitude(jsonMerchant2.getString("longitude"));
        parameterMerchant.setDecreaseMileage(jsonMerchant2.getString("decreaseMileage"));
        parameterMerchant.setPrSentence(jsonMerchant2.getString("prSentence"));
        parameterMerchant.setPrPicture01(jsonMerchant2.getString("prPicture01"));
        parameterMerchant.setPrPicture02(jsonMerchant2.getString("prPicture02"));
        parameterMerchant.setPrPicture03(jsonMerchant2.getString("prPicture03"));
        parameterMerchant.setPrPicture04(jsonMerchant2.getString("prPicture04"));
        parameterMerchant.setPrPicture05(jsonMerchant2.getString("prPicture05"));
        parameterMerchant.setRestrictionYn(jsonMerchant2.getString("restrictionYn"));
        parameterMerchant.setGrade(jsonMerchant2.getString("grade"));
        parameterMerchant.setActivateYn(jsonMerchant2.getString("activateYn"));
        parameterMerchant.setModifyDate(jsonMerchant2.getString("modifyDate"));
        parameterMerchant.setRegisterDate(jsonMerchant2.getString("registerDate"));

        CheckMileageMerchant resultMerchant = new CheckMileageMerchant();

        try {
            checkMileageMerchantService.registerMerchant(parameterMerchant);
            resultMerchant.setResult("SUCCESS");
        } catch (Exception e) {
            resultMerchant.setResult("FAIL");
            logger.error("Fail to register merchant.");
        }

        return resultMerchant;
    }

    /**
     * 서비스 로그인을 한다.
     *
     * @param is
     * @return
     * @throws Exception
     */
    @POST
    @Path("/login")
    @Consumes({"application/json", "application/xml"})
    @Produces({"application/json", "application/xml"})
    public CheckMileageMerchant login(InputStream is) throws Exception {
        logger.info("login");

        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = br.readLine();

        logger.info("line : {}", line);

        JSONObject jsonMerchant = new JSONObject(line);
        JSONObject jsonMerchant2 = jsonMerchant.getJSONObject("checkMileageMerchant");

        CheckMileageMerchant parameterMerchant = new CheckMileageMerchant();

        parameterMerchant.setMerchantId(jsonMerchant2.getString("merchantId"));
        parameterMerchant.setPassword(checkMileageCommon.getEncodedPassword(jsonMerchant2.getString("password")));
        parameterMerchant.setRestrictionYn("Y");           // 사용 제한 여부.
        parameterMerchant.setActivateYn(jsonMerchant2.getString("activateYn"));

        logger.info("merchantId    : {}", parameterMerchant.getMerchantId());
        logger.info("password      : {}", parameterMerchant.getPassword());
        logger.info("restrictionYn : {}", parameterMerchant.getRestrictionYn());
        logger.info("activateYn    : {}", parameterMerchant.getActivateYn());

        return checkMileageMerchantService.login(parameterMerchant);
    }

    /**
     * 가맹점 정보를 가져 온다.
     * 
     * @param is
     * @return
     * @throws Exception
     */
    @POST
    @Path("/selectMerchantInformation")
    @Consumes({"application/json", "application/xml"})
    @Produces({"application/json", "application/xml"})
    public CheckMileageMerchant selectMerchantInformation(InputStream is) throws Exception {
        logger.info("selectMerchantInformation");

        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = br.readLine();

        logger.info("line : {}", line);

        JSONObject jsonMerchant = new JSONObject(line);
        JSONObject jsonMerchant2 = jsonMerchant.getJSONObject("checkMileageMerchant");

        CheckMileageMerchant parameterMerchant = new CheckMileageMerchant();

        parameterMerchant.setMerchantId(jsonMerchant2.getString("merchantId"));
        parameterMerchant.setActivateYn(jsonMerchant2.getString("activateYn"));

        return checkMileageMerchantService.selectMerchantInformation(parameterMerchant);
    }

    /**
     * 가맹점 정보를 수정 한다.
     * 
     * @param is
     * @return
     * @throws Exception
     */
    @POST
    @Path("/updateMerchantInformation")
    @Consumes({"application/json", "application/xml"})
    @Produces({"application/json", "application/xml"})
    public CheckMileageMerchant updateMerchantInformation(InputStream is) throws Exception {
        logger.info("updateMerchantInformation");

        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = br.readLine();

        logger.info("line : {}", line);

        JSONObject jsonMerchant = new JSONObject(line);
        JSONObject jsonMerchant2 = jsonMerchant.getJSONObject("checkMileageMerchant");

        CheckMileageMerchant parameterMerchant = new CheckMileageMerchant();

        parameterMerchant.setMerchantId(jsonMerchant2.getString("merchantId"));
        parameterMerchant.setPassword(jsonMerchant2.getString("password"));
        parameterMerchant.setName(jsonMerchant2.getString("name"));
        parameterMerchant.setCompanyName(jsonMerchant2.getString("companyName"));
        parameterMerchant.setIntroduction(jsonMerchant2.getString("introduction"));
        parameterMerchant.setProfileImageUrl(jsonMerchant2.getString("profileImageUrl"));
        parameterMerchant.setProfileThumbnailImageUrl(jsonMerchant2.getString("profileThumbnailImageUrl"));
        parameterMerchant.setBirthday(jsonMerchant2.getString("birthday"));
        parameterMerchant.setOpeningDate(jsonMerchant2.getString("openingDate"));
        parameterMerchant.setEmail(jsonMerchant2.getString("email"));
        parameterMerchant.setHomePage(jsonMerchant2.getString("homePage"));
        parameterMerchant.setBlog(jsonMerchant2.getString("blog"));
        parameterMerchant.setAgencyCode(jsonMerchant2.getString("agencyCode"));
        parameterMerchant.setCountryCode(jsonMerchant2.getString("countryCode"));
        parameterMerchant.setLanguageCode(jsonMerchant2.getString("languageCode"));
        parameterMerchant.setMobilePhoneNumber(jsonMerchant2.getString("mobilePhoneNumber"));
        parameterMerchant.setHomePhoneNumber(jsonMerchant2.getString("homePhoneNumber"));
        parameterMerchant.setWorkPhoneNumber(jsonMerchant2.getString("workPhoneNumber"));
        parameterMerchant.setFaxPhoneNumber(jsonMerchant2.getString("faxPhoneNumber"));
        parameterMerchant.setZipCode01(jsonMerchant2.getString("zipCode01"));
        parameterMerchant.setAddress01(jsonMerchant2.getString("address01"));
        parameterMerchant.setAddress02(jsonMerchant2.getString("address02"));
        parameterMerchant.setZipCode02(jsonMerchant2.getString("zipCode02"));
        parameterMerchant.setAddress03(jsonMerchant2.getString("address03"));
        parameterMerchant.setAddress04(jsonMerchant2.getString("address04"));
        parameterMerchant.setZipCode03(jsonMerchant2.getString("zipCode03"));
        parameterMerchant.setAddress05(jsonMerchant2.getString("address05"));
        parameterMerchant.setAddress06(jsonMerchant2.getString("address06"));
        parameterMerchant.setZipCode04(jsonMerchant2.getString("zipCode04"));
        parameterMerchant.setAddress07(jsonMerchant2.getString("address07"));
        parameterMerchant.setAddress08(jsonMerchant2.getString("address08"));
        parameterMerchant.setZipCode05(jsonMerchant2.getString("zipCode05"));
        parameterMerchant.setAddress09(jsonMerchant2.getString("address09"));
        parameterMerchant.setAddress10(jsonMerchant2.getString("address10"));
        parameterMerchant.setBusinessType(jsonMerchant2.getString("businessType"));
        parameterMerchant.setBusinessRegistrationNumber01(jsonMerchant2.getString("businessRegistrationNumber01"));
        parameterMerchant.setBusinessRegistrationNumber02(jsonMerchant2.getString("businessRegistrationNumber02"));
        parameterMerchant.setBusinessRegistrationNumber03(jsonMerchant2.getString("businessRegistrationNumber03"));
        parameterMerchant.setBusinessRegistrationNumber04(jsonMerchant2.getString("businessRegistrationNumber04"));
        parameterMerchant.setBusinessRegistrationNumber05(jsonMerchant2.getString("businessRegistrationNumber05"));
        parameterMerchant.setBusinessRegistrationNumber06(jsonMerchant2.getString("businessRegistrationNumber06"));
        parameterMerchant.setBusinessRegistrationNumber07(jsonMerchant2.getString("businessRegistrationNumber07"));
        parameterMerchant.setBusinessRegistrationNumber08(jsonMerchant2.getString("businessRegistrationNumber08"));
        parameterMerchant.setBusinessRegistrationNumber09(jsonMerchant2.getString("businessRegistrationNumber09"));
        parameterMerchant.setBusinessRegistrationNumber10(jsonMerchant2.getString("businessRegistrationNumber10"));
        parameterMerchant.setBusinessKind01(jsonMerchant2.getString("businessKind01"));
        parameterMerchant.setBusinessKind02(jsonMerchant2.getString("businessKind02"));
        parameterMerchant.setBusinessKind03(jsonMerchant2.getString("businessKind03"));
        parameterMerchant.setBusinessKind04(jsonMerchant2.getString("businessKind04"));
        parameterMerchant.setBusinessKind05(jsonMerchant2.getString("businessKind05"));
        parameterMerchant.setBusinessArea01(jsonMerchant2.getString("businessArea01"));
        parameterMerchant.setBusinessArea02(jsonMerchant2.getString("businessArea02"));
        parameterMerchant.setBusinessArea03(jsonMerchant2.getString("businessArea03"));
        parameterMerchant.setBusinessArea04(jsonMerchant2.getString("businessArea04"));
        parameterMerchant.setBusinessArea05(jsonMerchant2.getString("businessArea05"));
        parameterMerchant.setLatitude(jsonMerchant2.getString("latitude"));
        parameterMerchant.setLongitude(jsonMerchant2.getString("longitude"));
        parameterMerchant.setDecreaseMileage(jsonMerchant2.getString("decreaseMileage"));
        parameterMerchant.setPrSentence(jsonMerchant2.getString("prSentence"));
        parameterMerchant.setPrPicture01(jsonMerchant2.getString("prPicture01"));
        parameterMerchant.setPrPicture02(jsonMerchant2.getString("prPicture02"));
        parameterMerchant.setPrPicture03(jsonMerchant2.getString("prPicture03"));
        parameterMerchant.setPrPicture04(jsonMerchant2.getString("prPicture04"));
        parameterMerchant.setPrPicture05(jsonMerchant2.getString("prPicture05"));
        parameterMerchant.setRestrictionYn(jsonMerchant2.getString("restrictionYn"));
        parameterMerchant.setGrade(jsonMerchant2.getString("grade"));
        parameterMerchant.setActivateYn(jsonMerchant2.getString("activateYn"));
        parameterMerchant.setModifyDate(jsonMerchant2.getString("modifyDate"));

        CheckMileageMerchant resultMerchant = new CheckMileageMerchant();

        try {
            checkMileageMerchantService.updateMerchantInformation(parameterMerchant);
            resultMerchant.setResult("SUCCESS");
        } catch (Exception e) {
            resultMerchant.setResult("FAIL");
            logger.error("Fail to update merchant information.");
        }

        return resultMerchant;
    }

    /**
     * 가맹점의 서비스 사용을 제한 여부를 업데이트 한다.
     * 
     * @param is
     * @return
     * @throws Exception
     */
    @POST
    @Path("/updateRestrictionMerchant")
    @Consumes({"application/json", "application/xml"})
    @Produces({"application/json", "application/xml"})
    public CheckMileageMerchant updateRestrictionMerchant(InputStream is) throws Exception {
        logger.info("updateRestrictionMerchant");

        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = br.readLine();

        logger.info("line : {}", line);

        JSONObject jsonMerchant = new JSONObject(line);
        JSONObject jsonMerchant2 = jsonMerchant.getJSONObject("checkMileageMerchant");

        CheckMileageMerchant parameterMerchant = new CheckMileageMerchant();

        parameterMerchant.setMerchantId(jsonMerchant2.getString("merchantId"));
        parameterMerchant.setRestrictionYn(jsonMerchant2.getString("restrictionYn"));
        parameterMerchant.setActivateYn(jsonMerchant2.getString("activateYn"));
        parameterMerchant.setModifyDate(jsonMerchant2.getString("modifyDate"));

        CheckMileageMerchant resultMerchant = new CheckMileageMerchant();

        try {
            checkMileageMerchantService.updateRestrictionMerchant(parameterMerchant);
            resultMerchant.setResult("SUCCESS");
        } catch (Exception e) {
            resultMerchant.setResult("FAIL");
            logger.error("Fail to update restriction merchant.");
        }

        return resultMerchant;
    }

    /**
     * 가맹점의 활성화 여부를 업데이트 한다.
     * 
     * @param is
     * @return
     * @throws Exception
     */
    @POST
    @Path("/updateDeactivateMerchant")
    @Consumes({"application/json", "application/xml"})
    @Produces({"application/json", "application/xml"})
    public CheckMileageMerchant updateDeactivateMerchant(InputStream is) throws Exception {
        logger.info("updateDeactivateMerchant");

        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = br.readLine();

        logger.info("line : {}", line);

        JSONObject jsonMerchant = new JSONObject(line);
        JSONObject jsonMerchant2 = jsonMerchant.getJSONObject("checkMileageMerchant");

        CheckMileageMerchant parameterMerchant = new CheckMileageMerchant();

        parameterMerchant.setMerchantId(jsonMerchant2.getString("merchantId"));
        parameterMerchant.setActivateYn(jsonMerchant2.getString("activateYn"));

        CheckMileageMerchant resultMerchant = new CheckMileageMerchant();

        try {
            checkMileageMerchantService.updateDeactivateMerchant(parameterMerchant);
            resultMerchant.setResult("SUCCESS");
        } catch (Exception e) {
            resultMerchant.setResult("FAIL");
            logger.error("Fail to update deactivate merchant.");
        }

        return resultMerchant;
    }

    /**
     * 가맹점 위치 정보를 업데이트 한다.
     *
     * @param is
     * @return
     * @throws Exception
     */
    @POST
    @Path("/updateMerchantLocation")
    @Consumes({"application/json", "application/xml"})
    @Produces({"application/json", "application/xml"})
    public CheckMileageMerchant updateMerchantLocation(InputStream is) throws Exception {
        logger.info("updateDeactivateMerchant");

        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = br.readLine();

        logger.info("line : {}", line);

        JSONObject jsonMerchant = new JSONObject(line);
        JSONObject jsonMerchant2 = jsonMerchant.getJSONObject("checkMileageMerchant");

        CheckMileageMerchant parameterMerchant = new CheckMileageMerchant();

        parameterMerchant.setMerchantId(jsonMerchant2.getString("merchantId"));
        parameterMerchant.setActivateYn(jsonMerchant2.getString("activateYn"));
        parameterMerchant.setLatitude(jsonMerchant2.getString("latitude"));
        parameterMerchant.setLongitude(jsonMerchant2.getString("longitude"));

        CheckMileageMerchant resultMerchant = new CheckMileageMerchant();

        try {
            checkMileageMerchantService.updateMerchantLocation(parameterMerchant);
            resultMerchant.setResult("SUCCESS");
        } catch (Exception e) {
            resultMerchant.setResult("FAIL");
            logger.error("Fail to update merchant location.");
        }

        return  resultMerchant;
    }

    /**
     * 검색한 가맹점 목록을 가져 온다.
     *
     * @param is
     * @return
     * @throws Exception
     */
    @POST
    @Path("/selectSearchMerchantList")
    @Consumes({"application/json", "application/xml"})
    @Produces({"application/json", "application/xml"})
    public List<CheckMileageMerchant> selectSearchMerchantList(InputStream is) throws Exception {
        logger.info("selectSearchMerchantList");

        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = br.readLine();

        logger.info("line : {}", line);

        JSONObject jsonMerchant = new JSONObject(line);
        JSONObject jsonMerchant2 = jsonMerchant.getJSONObject("checkMileageMerchant");

        CheckMileageMerchant parameterMerchant = new CheckMileageMerchant();

        parameterMerchant.setCheckMileageId(jsonMerchant2.getString("checkMileageId"));
        parameterMerchant.setBusinessKind03(jsonMerchant2.getString("businessKind03"));
        parameterMerchant.setCompanyName(jsonMerchant2.getString("companyName"));
        parameterMerchant.setRestrictionYn("Y");    // 서비스 사용 허가된 가맹점만 검색 가능하다.
        parameterMerchant.setGrade("5");            // 일반 가맹점만 검색 가능하다.
        parameterMerchant.setActivateYn(jsonMerchant2.getString("activateYn"));

        logger.info("checkMileageId : {}", parameterMerchant.getCheckMileageId());
        logger.info("businessKind03 : {}", parameterMerchant.getBusinessKind03());
        logger.info("companyName    : {}", parameterMerchant.getCompanyName());
        logger.info("restrictionYn  : {}", parameterMerchant.getRestrictionYn());
        logger.info("activateYn     : {}", parameterMerchant.getActivateYn());
        logger.info("grade          : {}", parameterMerchant.getGrade());

        return checkMileageMerchantService.selectSearchMerchantList(parameterMerchant);
    }

    /**
     * 모든 가맹점 목록을 가져 온다.(JSon 테스트용도)
     *
     * @return
     * @throws Exception
     */
    @POST
    @Path("/selectMerchantList")
    @Consumes({"application/json", "application/xml"})
    @Produces({"application/json", "application/xml"})
    public List<CheckMileageMerchant> selectMerchantList() throws Exception {
        logger.info("selectMerchantList");

        return checkMileageMerchantService.selectMerchantList();
    }
}
